package router

import (
	"go-proxy/common"
	"go-proxy/config"
	"net/http"
	"regexp"
)

type RegexRouter struct {
}

func NewRegexRouter() *RegexRouter {
	return &RegexRouter{}
}

func (re *RegexRouter) checkPath(route *config.Route, r *http.Request) bool {
	compile, err := regexp.Compile(route.Path)
	if err != nil {
		common.LogError("RegexRouter regex:", route.Path, " error:", err)
		return false
	}

	return compile.MatchString(r.URL.Path)
}
